export function useLoading(initValue = false) {
  const loading = ref(initValue)

  const setLoading = (value: boolean) => {
    loading.value = value
  }

  const showLoading = () => {
    loading.value = true
  }
  const hideLoading = () => {
    loading.value = false
  }

  const toggleLoading = () => {
    loading.value = !loading.value
  }

  // 数组是对应位置命名的，可以方便重命名，对象对于类型和语法提示更加友好。
  return { loading, showLoading, hideLoading, setLoading, toggleLoading }
}
